import pandas as pd
df_population = pd.read_csv(r"D:\py\pythonProject\population-data\data\temp\分省常驻人口数据.csv",encoding="gbk")
df_s = pd.read_csv(r"D:\py\pythonProject\population-data\data\originalData\分省面积数据（万平方公里） .csv",encoding="gbk")

df_midu = pd.read_csv(r"D:\py\pythonProject\population-data\data\temp\分省常驻人口数据.csv",encoding="gbk")
years = [str(year) for year in range(2023, 1949, -1)]
for i in range(len(years)-1):
    df_midu[years[i] + "年"] = round(df_population[years[i] + "年"] / df_s["2023年"], 2)

print(df_midu.iloc[:, 1:])

df_midu.to_csv(r"D:\py\pythonProject\population-data\data\temp\分省人口密度.csv",encoding="gbk",index=False)